package org.zjt.mock.demo.mock.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * Description:
 *
 * @author juntao.zhang
 * Date: 2018-06-21 下午2:58
 * @see
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ResultMsg<T> {

    private String msg;

    private Integer code;

    private T data;


    public static<T> ResultMsg<T> OK(T data) {
        ResultMsg<T> ok = new ResultMsg<>("OK",200,data);
        return ok;
    }

    public static<T> ResultMsg<T> error(T data,String msg) {
        ResultMsg<T> error = new ResultMsg<>(msg,500,data);
        return error;
    }

    public static<T> ResultMsg<T> error(String msg) {
        ResultMsg<T> error = new ResultMsg();
        error.setMsg(msg);
        error.setCode(500);
        return error;
    }
}
